![]() |
WOLF core
WOLF: A Modular Estimation Framework for Robotics
|
#include <core/utils/eigen_assert.h>
Public Member Functions | |
| template<typename T > | |
| StaticDimCheck (const T &) | |
Check Eigen Matrix sizes, both statically and dynamically
Help:
The WOLF project implements many template functions using Eigen Matrix and Quaterniond, in different versions (Static size, Dynamic size, Map, Matrix expression).
Eigen provides some macros for STATIC assert of matrix sizes, the most common of them are (see Eigen's StaticAssert.h):
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE EIGEN_STATIC_ASSERT_VECTOR_ONLY
but they do not work if the evaluated types are of dynamic size.
In order to achieve full templatization over both dynamic and static sizes, we use extensively a prototype of this kind:
template<typename Derived> inline Eigen::Matrix<typename Derived::Scalar, 3, 3> function(const Eigen::MatrixBase<Derived>& _v){
MatrixSizeCheck<3,1>::check(_v); /// We check here the size of the input parameter typedef typename Derived::Scalar T; ... code ... return M; }
The function : MatrixSizeCheck <Rows, Cols>::check(M) checks that the Matrix M is of size ( Rows x Cols ). This check is performed statically or dynamically, depending on the type of argument provided.
|
inline |